<?php
/**
 * 订单列表控制器
 * @author e5
 *
 */
class OrderListController extends CommonController{
	private $db;
	public function __init() {
		parent::__init();
		$this->checkLogin();
		$this->db = K("OrderList");
	}
	/**
	 * 订单列表显示
	 */
	public function index(){
		$oid = Q("get.oid",0,"intval");
		$uid = session("uid");
		//获得订单信息
		$orderData = K("Order")->where("oid={$oid} AND vshop_user_uid={$uid}")->find();
		if(empty($orderData)) go(U("Order/index"));
		switch ($orderData['ostatus']){
			case 0:
				$orderData['status'] = "进行中";
				break;
			case 1:
				$orderData['status'] = "已完成";
				break;
			default:
				$orderData['status'] = '无效';
				break;
		}
		$this->assign("orderData",$orderData);
		//获得商品信息
		$orderListData = M()->field("g.gname,g.gid,ol.*")->join("__orderlist__ ol JOIN __goodslist__ gl ON ol.vshop_goodslist_glid=gl.glid JOIN __goods__ g ON gl.vshop_goods_gid=g.gid")->where("ol.vshop_order_oid={$oid}")->all();
		$this->assign("goodsData",$orderListData);
		$this->dis("orderList");
	}
}